package com.lingyu.pojo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Page<T> {

	private int curPage = 1;
	private int start = 0;

	private int pageSize = 4;

	private int recordCount;
	private int pageCount;

	private List<T> data;
	private Map<String, Object> conditions = new HashMap<String, Object>(); // stuName:xx

	public int getCurPage() {
		return curPage;
	}

	public void setCurPage(int curPage) {
		this.curPage = curPage;
		this.start = (this.curPage - 1) * this.pageSize;
	}

	public int getStart() {
		return start;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
		this.pageCount = this.recordCount / this.pageSize;
		if (this.recordCount % this.pageSize != 0) {
			this.pageCount++;
		}
		
		if(this.pageCount<this.curPage){
			setCurPage(1);
		}
	}

	public int getPageCount() {
		return pageCount;
	}

	// public void setPageCount(int pageCount) {
	// this.pageCount = pageCount;
	// }
	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public Map<String, Object> getConditions() {
		return conditions;
	}

//	public void setConditions(String key, Object value) {
//		this.conditions.put(key, value.toString().trim().length()==0?null:value);
//
//	}

}
